/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package net.wofly.cashier.preorder.repository;

import net.wofly.cashier.preorder.domain.BookMeal;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

public interface BookMealRepository
		extends PagingAndSortingRepository<BookMeal, String>, JpaSpecificationExecutor<BookMeal> {
	
	BookMeal findByTableIDAndStatusAndBookMealTimeBetween(String tableID, Integer status, Long startTime, Long endTime);

	@Query(value = "select bookMealNo from cashier_preorder_bookmeal where bookMealTime between :dayStartTime and :dayEndTime " +
			"order by bookMealNo desc", nativeQuery = true)
	Integer findByBookMealTimeBetween(@Param("dayStartTime") long dayStartTime, @Param("dayEndTime") long dayEndTime);
}